home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / programming / assembly / ex4_number2 / playsample.s / playsample.s
Encoding:
Text File  |  1992-09-02  |  2.1 KB  |  78 lines

  1. *******************************************************************************
  2. * PT_Sample
  3. * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  4. * Plays a digital sound sample though a specified sound channel with frequency
  5. * and volume. Its checks if the ProTracker replayer is playing and disables
  6. * the sound channel..plays sample, then re-enables the channel with old params.
  7. *
  8. * INPUTS ; a1=Pt to Sample Structure;
  9. *     ; d3=Channel to use.
  10. * e.g;
  11. * SampleStruct    dc.l    Sample,Sampend-Sample    ;sample pt, sample length
  12. *        dc.w    $40,400                ;volume, frequency
  13. *        ...
  14. *
  15. * OUTPUTS; None.. Sample will be stopped using sample interrupt (lev6 access)
  16. *******************************************************************************
  17.  
  18.         include    includes:misc/_hardware.i
  19.  
  20.         lea    samplestruct(pc),a1
  21.         moveq    #0,d3
  22.         bsr    pt_sample
  23.         rts
  24.         
  25. PT_Sample:    move.l    (a1)+,a0        ;sample ptr
  26.         move.l    (a1)+,d0        ;sample length
  27.         move.w    (a1)+,d1        ;volume
  28.         move.w    (a1)+,d2        ;frequency
  29.  
  30.         lea    $dff000.l,a5        ;hardware base in a5
  31.         lsr.w    #1,d0            ;get correct length
  32.  
  33.         move.w    #$780,d4        ;audio 0 intena
  34.         move.w    #$800f,d5        ;audio 0 channel dma
  35.  
  36.         lea    Aud0lch(a5),a6        ;audio 0 ptr
  37.         move.w    #7,d6            ;audio 0 intreqr finished
  38.         tst.b    d3
  39.         beq.s    PlaySamp
  40.  
  41.         lea    Aud1lch(a5),a6        ;audio 1 ptr
  42.         move.w    #8,d6            ;audio 1 intreqr finished
  43.         cmp.b    #1,d3
  44.         beq.s    PlaySamp
  45.  
  46.         lea    Aud2lch(a5),a6        ;audio 2 ptr
  47.         move.w    #9,d6            ;audio 2 intreqr finished
  48.         cmp.b    #2,d3
  49.         beq.s    PlaySamp
  50.  
  51.         lea    Aud3lch(a5),a6        ;audio 3 ptr
  52.         move.w    #10,d6            ;audio 3 intreqr finished
  53.         
  54. PlaySamp:    move.l    a0,(a6)+        ;sample ptr
  55.         move.w    d0,(a6)+        ;length of sample
  56.         move.w    d2,(a6)+        ;Use Frequency
  57.         move.w    d1,(a6)            ;Volume
  58.  
  59.         move.w    d4,IntReq(a5)        ;set intreq
  60.         move.w    d5,dmacon(a5)        ;sound dma on for channel
  61.     
  62.         moveq    #2-1,d1            ;2 tests
  63. IWait1        move.w    $1e(a5),d0        ;intreqr
  64.         btst    d6,d0            ;signalled yet?
  65.         beq.s    IWait1            ;no, keep loopin`
  66.         move.w    d4,IntReq(a5)        ;set intreq
  67.         move.w    d5,dmacon(a5)        ;sound dma on for channel
  68.         dbf    d1,IWait1        ;keepon
  69.  
  70.         clr.w    (a6)            ;clear sound volume
  71.         rts
  72.  
  73. samplestruct    dc.l    sample,sampleend-sample
  74.         dc.w    $40,400
  75.         
  76. sample        incbin    'comms:done.raw'
  77. sampleend    even
  78.